<template>
  <div class="h-100">
    <!-- 路由列表 -->
    <LinkSegmentList
      ref="LinkSegmentList"
      page-name="alarm"
      @operate="operate"
      @showAlarmConfig="operateAlarmConfig"
    />
    <!-- 新增路由弹窗 -->
    <edit :visible="editShow" :row-data="rowData" @close="closeEdit" />
    <!-- 告警配置 -->
    <AlarmConfig :visible="showConfig" @close="closeEdit" />
    <AlarmLevel :visible="showLevel" @close="closeEdit" />
  </div>
</template>

<script>
  import Edit from './Edit'
  import LinkSegmentList from '@/components/LinkSegmentList'
  import AlarmConfig from './AlarmConfig'
  import AlarmLevel from './AlarmLevel'

  export default {
    components: {
      Edit,
      LinkSegmentList,
      AlarmConfig,
      AlarmLevel
    },
    data() {
      return {
        rowData: {},
        editShow: false,
        showConfig: false,
        showLevel: false,
        functionName: 'alarm'
      }
    },
    provide() {
      return {
        functionName: 'alarm',
        parentVM: this
      }
    },
    methods: {
      operateAlarmConfig(type) {
        if (type === 'config') {
          this.showConfig = true
        } else {
          this.showLevel = true
        }
      },
      loadData() {
        this.$refs.LinkSegmentList && this.$refs.LinkSegmentList.loadData()
      },
      // 修改
      operate(data) {
        this.rowData = data.data
        this.editShow = true
      },
      // 弹窗关闭
      closeEdit(load) {
        this.editShow = false
        this.showConfig = false
        this.showLevel = false
        if (load === true) {
          this.loadData()
        }
      }
    }
  }
</script>

<style></style>
